home *** CD-ROM | disk | FTP | other *** search
- /**
- * AppComponent
- */
- function NOF_AppComponent(componentName, installFile) {
- this.__proto__ = NOF_AppComponent.prototype;
-
- this.componentName = componentName;
- this.installFile = installFile;
-
- this.application = null;
-
- this.comp = NOF.App.getFSIApp().GetCurrentComponent();
-
- //return this;
- }
-
- //function NOF_AppComponent_ProtoBuilder()
- {
-
- var method = NOF_AppComponent.prototype;
- method.CLASS_NAME = "NOF.AppComponent";
-
- method.CONFIG_DIALOG_PATH = "Configure.html";
- method.COMPONENT_CLASS = null;
-
- method.MAX_INSTANCES_IN_PAGE = -1;
- method.MAX_SAME_CLASS_INSTANCES = -1;
-
- method.MAX_INSTANCES_EXCEEDED = "MAX_INSTANCES_EXCEEDED";
- method.MAX_CLASS_INSTANCES_EXCEEDED= "MAX_CLASS_INSTANCES_EXCEEDED";
- //these constants can be moved outside this class
- method.POST_FORM_METHOD = "POST";
- method.GET_FORM_METHOD = "GET";
-
- //Width of the component in Page view.
- method.setWidth = function (width) { this.comp.Width = width; }
- method.getWidth = function () { return this.comp.Width; }
- //Height of the component in Page view.
- method.setHeight = function (height) { this.comp.Height = height; }
- method.getHeight = function () { return this.comp.Height; }
-
- method.setOutputCode = function (code) { this.comp.SetHTML(code); }
- method.setHeaderScript = function (pId, code) { this.comp.SetHeaderScript(p,Id, code); }
- method.setBodyEventHandler = function (pId, pHandler) { this.comp.SetBodyEventHandler(p,Id, pHandler); }
- method.addFile = function (filePath, pNumber) { this.comp.AddFile(filePath, pNumber); }
- method.removeFile = function (pNumber) { this.comp.RemoveFile(pNumber); }
- method.setPreviewHTML = function (pHTML) { this.comp.SetPreviewHTML(pHTML); }
- method.getNode = function () { return this.comp.GetNode(); }
- method.getBackgroundColor = function () { return this.comp.GetBackgroundColor(); }
-
- method.setIsFullyConfigured= function (configured) { this.comp.Initialized = configured; }
- method.isFullyConfigured = function () { return this.comp.Initialized; }
-
- method.setComponentClass = function (className) { this.comp.Class = className; }
- method.getComponentClass = function () { return this.comp.Class; }
-
- method.setComponentName = function (compName) { this.comp.Name = this.componentName = compName; }
- method.getComponentName = function () { return this.comp.Name; }
-
-
- method.setRequiresUpdate = function (require) { this.comp.RequiresUpdate = require; }
- method.requiresUpdate = function () { return this.comp.RequiresUpdate; }
-
- method.getApplication = function () {return this.application}
- method.setApplication = function (app) {return (this.application = app); }
-
- //abstract, should be implemented in subclasses
- method.handleExceedInstancesLimit = function () {}
-
- method.setIsFormElement = function (isFormElem) { this.comp.IsFormElement = isFormElem; }
- method.isFormElement = function () { return this.comp.IsFormElement; }
-
- method.isControlingFormAction = function () { return this.comp.ControlsFormAction; }
- method.setIsControlingFormAction = function (controlsAction) { this.comp.ControlsFormAction = controlsAction; }
- // call setIsControlingFormAction(true) before setFormAction
- method.setFormAction = function (formAction) { this.comp.FormAction = formAction; }
- method.getFormAction = function () { return this.comp.FormAction; }
-
- method.isControlingFormMethod = function () { return this.comp.ControlsFormMethod; }
- method.setIsControlingFormMethod = function (controlsMethod) { this.comp.ControlsFormMethod = controlsMethod; }
- // call setIsControlingFormMethod(true) before setFormMethod
- method.setFormMethod = function (formMethod) { this.comp.FormMethodIsPost = (formMethod == this.POST_FORM_METHOD); }
- method.getFormMethod = function () { return (this.comp.FormMethodIsPost) ? this.POST_FORM_METHOD : this.GET_FORM_METHOD; }
-
- method.isControlingFormEncoding = function () { return this.comp.ControlsFormEncoding; }
- method.setIsControlingFormEncoding = function (controlsEncoding) { this.comp.ControlsFormEncoding = controlsEncoding; }
- // call setIsControlingFormEncoding(true) before setFormEncoding
- method.setFormEncoding = function (formEncoding) { this.comp.FormEncoding = formEncoding; }
- method.getFormEncoding = function () { return this.comp.FormEncoding; }
-
- method.initialize = function () {
- var METHOD_NAME = "initialize";
- //cfgLogger.info("init NOF.AppComponent", "NOF.AppComponent", METHOD_NAME);
- //cfgLogger.info("set Name="+this.componentName+", location="+this.INSTALL_PATH, "NOF.AppComponent", METHOD_NAME);
- //this.comp.Name = this.componentName;
- this.setComponentName(this.componentName);
-
- this.comp.Location = this.INSTALL_PATH + this.installFile; //+ this.componentName;
- if (this.COMPONENT_CLASS != null) {
- this.setComponentClass(this.COMPONENT_CLASS);
- }
-
- if ( this.MAX_INSTANCES_IN_PAGE > 0 ) {
- if ( this.exceedMaxInstancesInPage() ) {
- //try {
- //abstract method
- this.handleExceedInstancesLimit( this.MAX_INSTANCES_EXCEEDED );
- //} catch(excd) {
- // //cfgLogger.warn("AppComponent.initialize got "+excd);
- // return;
- //}
- }
- }
-
- if ( (this.COMPONENT_CLASS != null) && (this.MAX_SAME_CLASS_INSTANCES > 0) ) {
- if ( this.exceedMaxClassInstancesInPage() ) {
- //try {
- //abstract method
- this.handleExceedInstancesLimit( this.MAX_CLASS_INSTANCES_EXCEEDED );
- //} catch(excd) {
- // //cfgLogger.warn("AppComponent.initialize got "+excd);
- // return;
- //}
- }
- }
-
- var appName = this.getApplication().getName();
- //cfgLogger.info("set appName="+appName, "NOF.AppComponent", METHOD_NAME);
- this.comp.Method = appName + ".dispatchEvent('ComponentMethod')";
- this.comp.OnCopy = appName + ".dispatchEvent('ComponentCopy')";
- this.comp.OnLoad = appName + ".dispatchEvent('ComponentLoad')";
- this.comp.OnDelete = appName + ".dispatchEvent('ComponentDelete')";
- //cfgLogger.info("all component's events set", "NOF.AppComponent", METHOD_NAME);
-
- this.setPlaceholderImage(this.placeholderImage);
-
- //cfgLogger.info("end", "NOF.AppComponent", METHOD_NAME);
- }
-
- /**
- * method getProperty
- */
- method.getProperty = function (key) {
- return (this.comp != null) ? this.comp.GetVar(key) : null;
- }
-
- /**
- * method setProperty
- */
- method.setProperty = function (key, value) {
- if (this.comp != null) {
- this.comp.SetVar(key, value);
- }
- }
-
-
- /**
- * method onComponentMethod
- */
- method.onComponentMethod = function () {
- var METHOD_NAME = "onComponentMethod";
-
- //cfgLogger.info("init ", "NOF.AppComponent", METHOD_NAME);
- try {
- var params = [ NOF, this.getApplication().getMainWindow(), this, eval(this.CLASS_NAME+"ConfigureDialog")];
- if ( this.NAMESPACE ) {
- params[params.length] = eval(this.NAMESPACE);
- }
- var configResult = window.showModalDialog(this.CONFIG_DIALOG_PATH, params, "status:no;help:no;border:thin;dialogWidth:400px;dialogHeight:430px;center:yes;scroll:no;");
- //cfgLogger.info("end with " + configResult, "NOF.AppComponent", METHOD_NAME);
- return configResult;
-
- } catch(err) {
- //cfgLogger.warning("ERROR", "NOF.AppComponent", METHOD_NAME, [err]);
- }
- }
-
- /**
- * method onComponentLoad
- */
- method.onComponentLoad = function () {
- var METHOD_NAME = "onComponentLoad";
- //cfgLogger.info(" init ", "NOF.AppComponent", METHOD_NAME);
- }
- /**
- * method onComponentCopy
- */
- method.onComponentCopy = function() {
- var METHOD_NAME = "onComponentCopy";
- //cfgLogger.info(" init ", "NOF.AppComponent", METHOD_NAME);
- }
- /**
- * method onComponentDelete
- */
- method.onComponentDelete = function () {
- var METHOD_NAME = "onComponentDelete";
- //cfgLogger.info(" init ", "NOF.AppComponent", METHOD_NAME);
- }
-
-
- /**
- * method setPlaceholderImage
- */
- method.setPlaceholderImage = function (imgPath) {
- var METHOD_NAME = "setPlaceholderImage";
- //cfgLogger.info(" imgPath="+imgPath, "NOF.AppComponent", METHOD_NAME);
-
- this.placeholderImage = imgPath;
- this.comp.SetPlaceholderImage(this.INSTALL_PATH + this.placeholderImage);
- }
-
- /**
- * method exceedMaxInstancesInPage
- */
- method.exceedMaxInstancesInPage = function () {
- var METHOD_NAME = "exceedMaxInstancesInPage";
- //cfgLogger.info("init", "NOF.AppComponent", METHOD_NAME);
- if ( this.MAX_INSTANCES_IN_PAGE <= 0 )
- return false;
- //var cIter = app2.GetComponentsOfClass( this.COMPONENT_CLASS );
- var cIter = this.getApplication().getFSIApp2().GetComponentsWithName( this.componentName );
-
- var no = cIter.count();
- var j = 0;
- var currentNode = this.getNode();
- for (var i=0; i < no; i++) {
- if ( currentNode.Number == cIter.GetNext().GetNode().Number )
- j++;
- }
- //cfgLogger.info(" no=" + no +" in current page = "+j, "NOF.AppComponent", METHOD_NAME);
- //cfgLogger.info("end. returns " + ( j > this.MAX_INSTANCES_IN_PAGE ), "NOF.AppComponent", METHOD_NAME);
- return ( j > this.MAX_INSTANCES_IN_PAGE );
- }
-
- /**
- * method exceedMaxClassInstancesInPage
- */
- method.exceedMaxClassInstancesInPage = function () {
- var METHOD_NAME = "exceedMaxClassInstancesInPage";
- //cfgLogger.info("init", "NOF.AppComponent", METHOD_NAME);
- //var app2 = new ActiveX("FSI.FSIApplication2");
- if ( (this.MAX_SAME_CLASS_INSTANCES <= 0) || (this.COMPONENT_CLASS == null) )
- return false;
- //var cIter = app2.GetComponentsOfClass( this.COMPONENT_CLASS );
- var cIter = this.getApplication().getFSIApp2().GetComponentsOfClass( this.COMPONENT_CLASS );
- //GetComponentsWithName(String pName)
- var no = cIter.count();
- var j = 0;
- var currentNode = this.getNode();
- for (var i=0; i < no; i++) {
- var pId = cIter.GetNext().GetNode().Number;
- //cfgLogger.info(" "+currentNode.Number+" = "+pId, "NOF.AppComponent", METHOD_NAME);
- if ( currentNode.Number == pId )
- j++;
- }
- //cfgLogger.info(" no=" + no +" in current page = "+j, "NOF.AppComponent", METHOD_NAME);
- //app2 = null;
- //cfgLogger.info("end. returns " + ( j > this.MAX_SAME_CLASS_INSTANCES ), "NOF.AppComponent", METHOD_NAME);
- return ( j > this.MAX_SAME_CLASS_INSTANCES );
- }
-
-
- /*
- * getAllComponents
- */
- method.getAllComponents = function () {
- var cmps = new Array();
- var cIter = null;
- if (arguments.length == 0) {
- cIter = this.getApplication().getFSIApp().GetAllComponents();
- } else if( arguments[0].toLowerCase() == "name" ) {
- cIter = this.getApplication().getFSIApp2().GetComponentsWithName(arguments[1]);
- } else if( arguments[0].toLowerCase() == "class" ) {
- cIter = this.getApplication().getFSIApp2().GetComponentsOfClass(arguments[1]);
- } else {
- return null;
- }
- var no = cIter.count();
- var cmp = null;
- var j = 0;
- for (var i=0; i < no; i++) {
- cmp = cIter.GetNext();
- try {
- j = cmps.length;
- eval("cmps[j] = new "+ cmp.Name +"()");
- cmps[j].comp = cmp;
- } catch(e) {
- //cfgLogger.warning("ERROR", "NOF.AppComponent", METHOD_NAME, [e]);
- }
- }
- return cmps;
- }
-
- /**
- * getComponentsWithName(String pName)
- **/
- method.getComponentsWithName = function (cName) {
- return this.getAllComponents("name", cName);
- }
-
- /**
- * getComponentsOfClass(String cClass)
- **/
- method.getComponentsOfClass = function (cClass) {
- return this.getAllComponents("class", cClass);
- }
- }
-
-
- //NOF_AppComponent_ProtoBuilder();
- NOF.__proto__.AppComponent = NOF_AppComponent;
-
-
-
-
- /*
- function runComponent(compName) {
- //cfgLogger.info("runComponent init, " + compName);
- var cmp = null;
- try {
- cmp = eval("new "+ compName + "()");
- cmp.initialize();
- //cmp.properties();
- //cmp.comp.Initialized = true;
- } catch(e) {
- alert(e.description);
- //cfgLogger.info("runComponent " + e.description);
- }
- //cfgLogger.info("runComponent end");
- return cmp;
- }
- */